<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../css/stylesite.css" medial="all" />
<link rel="stylesheet" type="text/css" href="../css/styleleft.css" medial="all" />
<link rel="stylesheet" type="text/css" href="../css/mystyle.css" />
	<script src="../js/jquery-1.8.2.min.js" ></script>
	<script src="../js/image.js" type="text/javascript"></script>
        <script src="../js/jsearch.js" type="text/javascript"></script>  
	<script type="text/javascript">
	$(function(){
		$(".button a").click(function(){
		$(this).parent().addClass('current');
		$(this).siblings().removeClass('current');
		});
		});
	</script>
<title>BÀI VIẾT - TIN TỨC</title>
</head>

<body class="pagebody">
	<div id="wrapwebsite" >
				<?php 
			include('../element/header.php');?>
			<div class="imagestop"></div>
			<div class="wrapmaincontent">
		<?php
		include('../element/leftside.php');
                include 'Article_model.php';
                 $display=5;
                        if(isset($_GET['page'])&&(int)$_GET['page'])
                        {
                            $page=$_GET['page'];	
                        }
                        else 
                        {
                            $page= getRecordAllowable($display);
                        }
                        $start=(isset($_GET['start']) && (int)$_GET['start']>=0) ? $_GET['start'] :0;
		?>
		<div class="center-leftmargin">                
                    <div class="modulecontent">
                                    <?php
                                        if (isset($_SESSION['logged']))
                                        {
                                            if ($_SESSION['logged']==true)
                                            {
                                                $User=$_SESSION['user'][1];
                                       echo '<a href="v_ArticlePost.php"><img src="../images/1354196486_mail_post.png" width="48px" height="48px" alt="Viết Bài" title="Viết Bài"> </a>';
                                    
                                            }
                                        }
                                    ?>
                        <?php 
                             $articles= getArticleAllow($start,$display);
                             foreach ($articles as $article) {      
                        ?>
                        <table width="700px" border="0" cellpadding="5px">
                            
                            <tr>
                                <td colspan="2"><a href="v_ArticleDetail.php?ID_Article=<?php echo $article[0]; ?>"><font size="4px" text-transform="uppercase" color="#B11824" font-weight="bold"> <?php echo $article[1]; ?></font></a></td>
                            </tr>
                             <tr>
                                <td colspan="2">Ngày đăng: <font size="2px"> <?php echo $article[4]; ?></font> &nbsp; &nbsp;Tác giả: <font size="3px" color="#973100"> <?php echo $article[3]; ?></font></td>
                            </tr>
                            <tr>
                                <td width="150px"><a href="v_ArticleDetail.php?ID_Article=<?php echo $article[0]; ?>"> <img src="<?php echo $article[8]; ?>" width="150px" height="150px"></a></td>
                                <td width="450px"> <?php echo substr($article[2], 0, 300).'...'; ?></td>
                            </tr>             
                        </table>
                            <?php 
                             }
                             ?>
                    </div>
                     <div class="botcontentright">
                            <ul class="nav">
                                 <?php 
                        if($page>1)
                        {//hien thi so trang
                            $next=$start+$display;
                            $prev=$start-$display;
                            $current=($start/$display)+1;
                            //hien thi trang Previous
                            if($current!=1)
                            {
                                    echo "<li><a href='v_Article.php?start=$prev'>Previous</a></li>";
                            }
                            //Hien thi so link
                            for($i=1;$i<=$page;$i++)
                            {
                                    if($current!= $i){
                                            echo "<li><a href='v_Article.php?start=".($display*($i-1))."'>$i</a></li>";
                                            
                                            }
                                    else {
                                            echo '<li class="currentpage">'.$i.'</li>';	
                                    }

                            }
                            //hien thi trang Next
                            if($current!=$page)
                            {
                                    echo "<li><a href='v_Article.php?start=$next'>Next</a></li>";
                            }
                        }
			
                        ?>
                            </ul>
                         
                        </div>
		</div>
		</div> 
		
		<?php include('../element/footer.php'); ?>
</div>
</body>
</html>
